# Author：wgw
# 思考题：names = [.....] 想找出重名的名字 ------> rename = [..]？
# 1、循环遍历每一个元素---->[]
# 2、如果遍历到某一个前面出现过，存到一个[]
# 3、计算重名个数？
#%%
names = ["金硕珍","闵玧其","金南俊","郑号锡","朴智旻","金泰亨","田柾国","朴智旻","田柾国","朴智旻"]
_names = []
rename = []
for bts in names:
    if bts not in _names: #1：当未有重复名单时
        _names.append(bts)   #将原名单导入一个新列表
    else:                 #2：当遇到重复的名单时
      if bts not in rename:  #2.1：如果rename列表中没有此重复名单
        rename.append(bts)   #将重复名单导入另一个列表
      else:                  #2.2:如果rename列表中已有该名单
          rename.extend([]) #利用“extend([])”什么也不做--以免在重复名单中 再次出现重复的名字
print(_names)
print("重复名单:",rename)

#计算个数
a = []
for i in names:
    if i in rename:
        if i not in a:
            print("the %s had found %d"%(i,names.count(i)))
        a.append(i)
    else:
        rename.extend([])
else:
    rename.extend([])



